cli: add Size column to \l+ and \dt+ #170978
Merged
Merged
Conversation
Contributor
|
😎 Merged successfully - details. |
|
Your pull request contains more than 1000 changes. It is strongly encouraged to split big PRs into smaller chunks. 🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf. |
Member
1d946b9 to
7f27a1a
Compare
PG's psql shows database and per-table on-disk sizes in the verbose variants of \l and \dt. CRDB's CLI carried explicit TODOs next to those columns waiting for the pg_database_size and pg_table_size builtins to exist. Now that both builtins (and pg_size_pretty) are available, wire them up. This makes the \l+ and \dt+ queries match Postgres exactly. The sizes come from the periodically-refreshed system.table_metadata cache and may lag the truth by minutes. TestDescribe gains a seed of system.table_metadata so the goldens exercise the real per-index lookup path. The details JSONB mirrors what tableMetadataUpdater writes in production (replica_count + primary_index_id + index_sizes), so we are not just relying on the mixed-version replication_size_bytes fallback. Resolves: cockroachdb#85834 Release note (cli change): The \l+ and \dt+ metacommands in the built-in SQL shell now include a Size column showing on-disk byte counts, matching PostgreSQL's psql. Database sizes come from pg_database_size; table sizes come from pg_table_size. Values are read from a periodically-refreshed internal cache and may lag the live byte count by minutes.
…k storage Virtual tables (pg_catalog, information_schema, crdb_internal) and physical tables whose system.table_metadata row hasn't been written yet now return NULL from pg_relation_size, pg_table_size, pg_total_relation_size, and pg_indexes_size, instead of 0. NULL is a truer signal than "0 bytes" for relations that have no on-disk concept, and it lets SUM-style aggregations skip those rows rather than adding meaningless zeros. Release note: None Co-Authored-By: roachdev-claude <roachdev-claude-bot@cockroachlabs.com>
7f27a1a to
0d85193
Compare
spilchen
approved these changes
May 28, 2026
spilchen
left a comment
Contributor
There was a problem hiding this comment.
nice to resolve a long standing issue
@spilchen partially reviewed 1 file and made 1 comment.
Reviewable status:complete! 1 of 0 LGTMs obtained (waiting on dhartunian).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
PG's psql shows database and per-table on-disk sizes in the verbose
variants of \l and \dt. CRDB's CLI carried explicit TODOs next to
those columns waiting for the pg_database_size and pg_table_size
builtins to exist. Now that both builtins (and pg_size_pretty) are
available, wire them up.
This makes the \l+ and \dt+ queries match Postgres exactly. The
sizes come from the periodically-refreshed system.table_metadata
cache and may lag the truth by minutes.
TestDescribe gains a seed of system.table_metadata so the goldens
exercise the real per-index lookup path. The details JSONB mirrors
what tableMetadataUpdater writes in production (replica_count +
primary_index_id + index_sizes), so we are not just relying on the
mixed-version replication_size_bytes fallback.
Resolves: #85834
Release note (cli change): The \l+ and \dt+ metacommands in the
built-in SQL shell now include a Size column showing on-disk byte
counts, matching PostgreSQL's psql. Database sizes come from
pg_database_size; table sizes come from pg_table_size. Values are
read from a periodically-refreshed internal cache
and may lag the live byte count by minutes.